/************************************************************************
 * Copyright (c) 2008 Sergei Stolyarov
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Program entry point.
 ************************************************************************/

#include <QtGui>

#include "controlwindow.h"
#include "myapplication.h"

/*
class MyApp : public QApplication
{
public:
    MyApp(int & argc, char ** argv) 
        : QApplication(argc, argv)
    {
        xkb = new XKeyboard();
    }

private:
    XKeyboard *xkb;

    bool x11EventFilter (XEvent * event)
    {
        xkb->processEvent(event);
        return false;
    }
    int x11ProcessEvent(XEvent* event)
    {
        xkb->processEvent(event);
        return QApplication::x11ProcessEvent(event);
    }
};
*/

int main(int argc, char *argv[])
{
    MyApplication app(argc, argv);

    if (!QSystemTrayIcon::isSystemTrayAvailable()) {
        QMessageBox::critical(0, QObject::tr("Systray"),
            QObject::tr("System tray is not found."));
        return 1;
    }

    QApplication::setQuitOnLastWindowClosed(false);

    ControlWindow win;
    QObject::connect(&app, SIGNAL(indicatorStateChanged(unsigned int)), &win, SLOT(indicatorsStateChanged(unsigned int)));
    app.forceGetIndicatorsState();

    // create tray icon
    
    win.show();

    return app.exec();
}
